home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / mint / mint108s.zoo / inline.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-06-25  |  1.9 KB  |  87 lines

  1. /*
  2. Copyright 1992 Eric R. Smith.
  3. Copyright 1993 Atari Corporation.
  4. All rights reserved.
  5.  */
  6.  
  7. /*
  8.  * inlining of various utility functions, for speed
  9.  * NOTE: ALL functions in this file must also have
  10.  * "normal" equivalents in the .c or .s files;
  11.  * don't put a function just into here!
  12.  */
  13.  
  14. #ifdef __GNUC__
  15.  
  16. #define spl7()            \
  17. ({  register short retvalue;    \
  18.     __asm__ volatile("        \
  19.     movew sr,%0;         \
  20.     oriw  #0x0700,sr "     \
  21.     : "=d"(retvalue)         \
  22.     ); retvalue; })
  23.  
  24. #define spl(N)            \
  25. ({                  \
  26.     __asm__ volatile("        \
  27.     movew %0,sr "         \
  28.     :                \
  29.     : "d"(N) ); })
  30.  
  31.  
  32. /*
  33.  * note that we must save some registers ourselves,
  34.  * or else gcc will run out of reggies to use
  35.  * and complain
  36.  */
  37.  
  38. #define callout1(func, a)            \
  39. ({                        \
  40.     register long retvalue __asm__("d0");    \
  41.     long _f = func;                \
  42.     short _a = (short)(a);            \
  43.                         \
  44.     __asm__ volatile            \
  45.     ("  moveml d5-d7/a4-a6,sp@-;        \
  46.         movew %2,sp@-;            \
  47.         jsr %1@;                \
  48.         addqw #2,sp;            \
  49.         moveml sp@+,d5-d7/a4-a6 "        \
  50.     : "=r"(retvalue)    /* outputs */    \
  51.     : "a"(_f), "r"(_a)    /* inputs */    \
  52.     : "d0", "d1", "d2", "d3", "d4",        \
  53.       "a0", "a1", "a2", "a3" /* clobbered regs */ \
  54.     );                    \
  55.     retvalue;                \
  56. })
  57.  
  58. #define callout2(func, a, b)            \
  59. ({                        \
  60.     register long retvalue __asm__("d0");    \
  61.     long _f = func;                \
  62.     short _a = (short)(a);            \
  63.     short _b = (short)(b);            \
  64.                         \
  65.     __asm__ volatile            \
  66.     ("  moveml d5-d7/a4-a6,sp@-;        \
  67.         movew %3,sp@-;            \
  68.         movew %2,sp@-;            \
  69.         jsr %1@;                \
  70.         addqw #4,sp;            \
  71.         moveml sp@+,d5-d7/a4-a6 "        \
  72.     : "=r"(retvalue)    /* outputs */    \
  73.     : "a"(_f), "r"(_a), "r"(_b) /* inputs */ \
  74.     : "d0", "d1", "d2", "d3", "d4",        \
  75.       "a0", "a1", "a2", "a3" /* clobbered regs */ \
  76.     );                    \
  77.     retvalue;                \
  78. })
  79.  
  80. #define flush_pmmu() __asm__ volatile("pflusha");
  81. #endif
  82.  
  83. #ifdef LATTICE
  84. #pragma inline d0=spl7()    {"40c0007c0700";}
  85. #pragma inline d0=spl(d0)    {"46c0";}
  86. #endif
  87.